const constant = require("../../util/constant.js");
const util = require('../../util/util.js');
const app = getApp();
Page({
  data: {
    CustomBar: app.globalData.CustomBar,
    jzlist:[],
    selkey:'',
    userid:''
  },
  onLoad:function(option){
    var myuid=wx.getStorageSync('userid');
    //console.log(myuid);
    if(myuid>0)
    {  
        
    }
    else
    {
        wx.redirectTo({
          url: '../login/index',
        })
    }
    var f=0;
    if(option.f!=null)
     f=option.f;
      //console.log("ok");
    this.aylist(f);
  },
  aylist(f)
  {
      var that=this;
    wx.request({
        url: constant.host+'/appserv/getmylstcw.ashx',
        data: {
          f:f,
          k: constant.wkey
        },
        success: function (data) {
          var dat = data.data;
          var pcname=[];
          var cpkey=[];
          var ayindex=0;
          
          for(var i=0;i<dat.length;i++)
          {
            dat[i].isShow=true;
            dat[i].AFDate=util.formatDate(dat[i].AFDate);
            
          }
          
          
          //console.log(orderlist.length);
          that.setData({
            jzlist:dat
          });
        }
      });
  },
  viewaj:function(e){
    let id=e.currentTarget.dataset["ajid"];
    //console.log(id);
    wx.navigateTo({
      url: 'jedit?id='+id,
    })
  },
  searchIcon(e) {
    let key = e.detail.value.toLowerCase();
    let list = this.data.jzlist;
    for (let i = 0; i < list.length; i++) {
      let a = key;
      let b = list[i].DSR.toLowerCase();
      let c=list[i].DSRHM;
      let d=list[i].AY;
      if (b.search(a) != -1 ||c.search(a)!=-1 || d.search(a)!=-1) {
        list[i].isShow = true
      } else {
        list[i].isShow = false
      }
    }
    this.setData({
      jzlist: list
    })
  }
})